<template></template>

<script setup>
import axios from 'axios';
import useAvtivityStore from "@/store/activity";
const activityStore = useAvtivityStore();

defineExpose({
  requestData,
  loadMilitaryData,
  loadGeneralData,
  loadImportantData,
})

function requestData() {
  loadMilitaryData();
  loadGeneralData();
  loadImportantData();
}

function loadMilitaryData() {
  return axios.get("api/activity_military_load.php").then(response => {
    if (response.data.status == 0) {
      // console.log('[info]', response.data);
    }
    if (response.data.data) {
      activityStore.militaryStatus = response.data.data;
    } else {
      console.log('[exception]', response.data);
    }

  }).catch(error => console.error(error));
}

function loadGeneralData() {
  return axios.get("api/activity_general_load.php").then(response => {
    if (response.data.status == 0) {
      // console.log('[info]', response.data);
    }
    if (response.data.data != null) {
      activityStore.generalStatus = response.data.data;
    } else {
      activityStore.generalStatus = [];
      // console.log('[exception]', response.data);
    }
  }).catch(error => console.error(error));
}

function loadImportantData() {
  return axios.get("api/activity_important_load.php").then(response => {
    if (response.data.status == 0) {
      // console.log('[info]', response.data);
    }
    if (response.data.data) {
      activityStore.impotrantStatus = response.data.data;
    } else {
      console.log('[exception]', response.data);
    }
  }).catch(error => console.error(error));
}
</script>